import http from './request.js'
import ENV_CONFIG from '@/env.js'
/* ---------------- 平台请求相关接口 start ---------------- */


const HCAPI = ENV_CONFIG.CONMON_SERVER_URL + '/hcapi'

// 登录
export const ftLogin = data => http.post(`${HCAPI}/wechat/user/login`, data);

// 推出登录
export const ftLogout = data => http.get(`${HCAPI}/wechat/user/logout`, data);

// 获取用户信息
export const ftUserInfo = data => http.get(`${HCAPI}/wechat/user/getUserInfo`, data);

// 修改用户信息
export const ftUpdate = data => http.post(`${HCAPI}/wechat/user/update`, data);

// 获取用户code
export const wxSilentLogin = () => {
	return new Promise((resolve, reject) => {
		uni.login({
			provider: "weixin",
			success(res) {
				resolve(res);
			},
			fail(err) {
				reject(err);
			},
		});
	});
};

// 手机登录流程
export const wxLogin = async (phoneCode) => {
	const {code} = await wxSilentLogin();
	console.log(code,phoneCode);
	const res = await ftLogin({
		wechatCode: code,
		phoneCode
	})
	return res
};


